import 'package:flutter/material.dart';
import 'package:kxy_flutter_app/model/exam.dart';

class ExamStatusWidget extends StatelessWidget {
  final Exam exam;
  const ExamStatusWidget({Key key, @required this.exam}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Color color;
    String text;
    if (exam.status == ExamStatus.NotStarted) {
      color = Color.fromRGBO(255, 199, 110, 1);
      text = '未开始';
    }

    if (exam.status == ExamStatus.Started) {
      color = Color.fromRGBO(102, 211, 159, 1);
      text = '进行中';
    }

    if (exam.status == ExamStatus.Ended) {
      color = Colors.black54;
      text = '已结束';
    }

    return Container(
      height: 17,
      width: 43,
      alignment: Alignment.center,
      margin: EdgeInsets.only(right: 5),
      decoration: BoxDecoration(
        color: color,
        borderRadius: BorderRadius.circular(3),
      ),
      child: Text(
        text,
        style: TextStyle(
          color: Colors.white,
          fontSize: 11,
        ),
      ),
    );
  }
}
